package com.hwadee.ems.domain.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import com.fasterxml.jackson.annotation.JsonIgnore;

import com.hwadee.ems.domain.po.Course;
import com.hwadee.ems.domain.po.ScheduledCourse;
import com.hwadee.ems.enums.Session;
import com.hwadee.ems.enums.DayOfWeek;
import com.hwadee.ems.service.IUserService;
import com.hwadee.ems.service.IClassService;
import com.hwadee.ems.service.ICourseService;
import com.hwadee.ems.service.ISemesterService;
import com.hwadee.ems.service.IClassroomService;
import com.hwadee.ems.service.IDepartmentService;
import com.hwadee.ems.service.impl.UserServiceImpl;
import com.hwadee.ems.service.impl.ClassServiceImpl;
import com.hwadee.ems.service.impl.CourseServiceImpl;
import com.hwadee.ems.service.impl.SemesterServiceImpl;
import com.hwadee.ems.service.impl.ClassroomServiceImpl;
import com.hwadee.ems.service.impl.DepartmentServiceImpl;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ScheduledCourseVO {

    @JsonIgnore
    private ICourseService courseService = CourseServiceImpl.getInstance();

    @JsonIgnore
    private IClassroomService classroomService = ClassroomServiceImpl.getInstance();

    @JsonIgnore
    private IClassService classService = ClassServiceImpl.getInstance();

    @JsonIgnore
    private IUserService userService = UserServiceImpl.getInstance();

    @JsonIgnore
    private IDepartmentService departmentService = DepartmentServiceImpl.getInstance(); 

    @JsonIgnore
    private ISemesterService semesterService = SemesterServiceImpl.getInstance();

    public ScheduledCourseVO(ScheduledCourse scheduledCourse) {
        this.id = scheduledCourse.getId();
        this.courseId = scheduledCourse.getCourseId();
        Course course = courseService.getById(this.courseId);
        this.courseName = course.getName();
        this.semesterId = course.getSemesterId();
        this.semester = semesterService.getById(this.semesterId).getName();
        this.startWeek = course.getStartWeek();
        this.endWeek = course.getEndWeek();
        this.weeks = startWeek + "-" + endWeek;
        this.attendence = scheduledCourse.getAttendence();
        this.dayOfWeek = scheduledCourse.getDayOfWeek();
        this.session = scheduledCourse.getSession();
        this.classroomId = scheduledCourse.getClassroomId();
        this.classroomName = classroomService.getById(this.classroomId).getName();
        this.classId = scheduledCourse.getClassId();
        this.className = classService.getById(this.classId).getName();
        this.teacherId = scheduledCourse.getTeacherId();
        this.teacherName = userService.getById(this.teacherId).getName();
        this.departmentId = scheduledCourse.getDepartmentId();
        this.departmentName = departmentService.getById(this.departmentId).getName(); 
    }

    private Long id;

    /**
     * 课程编号 references course(id) for (name, semester_id, start_week, end_week)
     */
    private Long courseId;

    /**
     * 课程名称
     */
    private String courseName;

    /**
     * 上课人数
     */
    private Integer attendence;

    /**
     * 开课学期编号 references semester(id) for (name)
     */
    private Long semesterId;

    /**
     * 开课学期
     */
    private String semester;

        /**
     * 上课开始周次
     */
    private Integer startWeek;

    /**
     * 上课结束周次
     */
    private Integer endWeek;

    /**
     * 上课周次
     */
    private String weeks;

    /**
     * 星期几，0代表星期日，1代表星期一，2代表星期二，3代表星期三，4代表星期四，5代表星期五，6代表星期六
     */
    private DayOfWeek dayOfWeek;

    /**
     * 上课节次，0代表1-2，1代表3-5，2代表6-7，3代表8-9，4代表10-12，5代表13-15
     */
    private Session session;

    /**
     * 上课教室编号 references classroom(id) for (name)
     */
    private Integer classroomId;

    /**
     * 上课教室名称
     */
    private String classroomName;

    /**
     * 上课班级编号 references class(id) for (name)
     */
    private Long classId;

    /**
     * 上课班级名称
     */
    private String className;

    /**
     * 授课老师编号 references user(id) for (name)
     */
    private Long teacherId;

    /**
     * 授课老师名称
     */
    private String teacherName;

    /**
     * 上课院系编号 references department(id) for (name)
     */
    private Long departmentId;

    /**
     * 上课院系名称
     */
    private String departmentName;
    
}
